[WIP] [Feature] Add some basic logging around request/response process. #511
Open
samLozier wants to merge 1 commit intoShopify:mainfrom
Open
[WIP] [Feature] Add some basic logging around request/response process. #511samLozier wants to merge 1 commit intoShopify:mainfrom
samLozier wants to merge 1 commit intoShopify:mainfrom
Conversation
…rrently problematic queries are difficult to debug, this should make it easier.
Contributor
|
A thought: pyactiveresource has its own logging, perhaps we can take advantage of that instead of creating our own log statements? |
Author
|
@mllemango Thanks, I didn't realize that and will take a look. I suppose the question might be moot if I end up using the pyactiveresource logging, but any thoughts on the <3.7 compatibility question? |
Contributor
|
Oh yes, sorry, fully support dropping pre 3.7 compatibility |
slyapustin
reviewed
May 8, 2022
| def _open(self, *args, **kwargs): | ||
| self.response = None | ||
| try: | ||
| log.debug(f"Request: {args, kwargs}") |
There was a problem hiding this comment.
Hey @samLozier, I think it's better to use different patterns when you do log messages:
log.debug("Request: %s, %s", args, kwargs).
Here is an article on that: https://google.github.io/styleguide/pyguide.html#3101-logging
slyapustin
reviewed
May 8, 2022
| request = urllib.request.Request(url, urllib.parse.urlencode(query_params).encode("utf-8")) | ||
| log.debug(f"Request URL: {url}, query params: {query_params}") | ||
| response = urllib.request.urlopen(request) | ||
| logging.debug(f"Response: {response}") |
There was a problem hiding this comment.
I think you want to use log.debug(...) here instead.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, problematic queries are difficult to debug, this should make slightly it easier.
WHY are these changes introduced?
PR is opened to address this discussion: #500
Fixes #500
Context about the problem that’s being addressed:
Adds some very rudimentary debug level logging in the session and base files.
Further discussion:
Checklist